//
//  MainMenuLayer.cpp
//  popstar
//
//  Created by luyuhuang on 14/11/27.
//
//

#include "MainMenuLayer.h"
#include "GamePlayScene.h"

bool MainMenuLayer::init()
{
    
    auto s = CCDirector::getInstance()->getWinSize();
    
    // Add background
    
    auto background = CCSprite::create("bg_menuscene.jpg");
    
    background->setAnchorPoint(Vec2(0.5, 0.5));
    background->setPosition(s.width/2, s.height/2);
    
    //background->runAction(ScaleTo::creat;
    
    addChild(background);
    // Add menu
    
    auto menuButton = CCMenuItemImage::create("menu_start.png", "menu_start.png", CC_CALLBACK_1(MainMenuLayer::menuCallBack, this));
    
    auto menu = CCMenu::create(menuButton,nullptr);
    
    
    this->addChild(menu);
    return true;
}

void MainMenuLayer::menuCallBack(Ref *sender) {
    
    CCLOG("Button touched!");
    
    auto playScene = GamePlayScene::create();
    
    Director::getInstance()->replaceScene(TransitionFlipX::create(1, playScene));
    
   // Director::getInstance()->replaceScene(playScene);
    
}